<?php
/*
|--------------------------------------------------------------------------
| Web Routes
|--------------------------------------------------------------------------
|
| Here is where you can register web routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| contains the "web" middleware group. Now create something great!
|
*/

Route::group(['namespace' => 'Admin' , 'prefix' => 'admin' ] , function(){
        Route::options('/{all}', function(\Illuminate\Http\Request $request) {
            $origin = $request->header('ORIGIN', '*');
            header("Access-Control-Allow-Origin: $origin");
            header("Access-Control-Allow-Credentials: true");
            header('Access-Control-Allow-Methods: POST, GET, OPTIONS, PUT, DELETE');
            header('Access-Control-Allow-Headers: Origin, Access-Control-Request-Headers, SERVER_NAME, Access-Control-Allow-Headers, cache-control, token, X-Requested-With, Content-Type, Accept, Connection, User-Agent, Cookie');
        })->where(['all' => '([a-zA-Z0-9-]|/)+']);

        Route::group(['middleware' => ['ao']], function (){
            
            Route::post('login' , 'AdminUsersController@doLogin');

            Route::group(['prefix' => 'AdminUsers'] , function (){
                Route::get('/', 'AdminUsersController@getList');
                Route::post('/update' , 'AdminUsersController@update');
                Route::post('/update/permission' , 'AdminUsersController@updatePermission');
            });
            Route::group(['prefix' => 'EatEveryDayPrize'] , function (){
                Route::get('/', 'EatEveryDayPrizeController@index');
                Route::post('/cash', 'EatEveryDayPrizeController@cashPrize');
            });
            Route::group(['prefix' => 'EatEveryDay'] , function (){
                Route::get('/', 'EatEveryDayController@index');
                Route::post('/Update/Eat', 'EatEveryDayController@getEatUpdate');
                Route::get('/getEat/{id}', 'EatEveryDayController@getEat');//编辑
                Route::get('/Delete/{id}', 'EatEveryDayController@Delete');//删除
            });
            Route::group(['prefix' => 'Banners'] , function (){
                Route::get('/', 'BannersController@index');
            });
            Route::group(['prefix' => 'Goods'] , function (){
                Route::get('/', 'GoodsController@index');
            });
            Route::group(['prefix' => 'Dashboard'] , function (){
                Route::get('/CountUsers', 'DashboardController@CountUsers');
                Route::get('/CountPrize', 'DashboardController@CountPrize');
                Route::get('/CountDay', 'DashboardController@CountDay');
            });
            Route::group(['prefix' => 'Users'] , function (){
                Route::get('/', 'UsersController@index');
                Route::post('/Update/Users', 'UsersController@getUsersUpdate');
                Route::get('/getUser/{id}', 'UsersController@getUser');//编辑
                Route::get('/Delete/{id}', 'UsersController@Delete');//删除
            });
        });

});